﻿using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
using Hx.Application.Configuration;
using Hx.Infrastructure;
using Hx.Infrastructure.Services;

namespace Hx.Service
{
    public class WebApiApplication : HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //Initializer instance,get the init instance to initialize the application.
            ServiceLocator.Instance.RegisterComponent("Hx.Infrastructure.IInitializer, Hx.Infrastructure", ConfigHelper.InitializerInstance);

            var initializer = ServiceLocator.Instance.GetService<IInitializer>();
            initializer.Start();
        }
    }
}